<template>
	<view class="">
		<u-navbar :bgColor="bgColor" title="服务协议" :titleStyle="titleStyle" leftIconColor="#ffffff"
			:autoBack="true"></u-navbar>
			<view class="" :style="{'height':globalData.navHeight-10 +'px'}"></view>
			
			<view class="contenBox">
				<rich-text type="text" :nodes="content"></rich-text>
			</view>
		
	</view>
</template>

<script>
	import { config} from "@/api/api.js"
	var graceRichText = require("../../static/richText.js");
	export default{
		data(){
			return{
				bgColor: "#F8AD22",
				titleStyle: {
					color: "#ffffff",
					fontSize: "32rpx",
					fontFamily: "PingFang SC-Bold, PingFang SC",
					fontweight: "bold",
				},
				globalData: {
					statusBarHeight: 0, // 状态导航栏高度
					navHeight: 0, // 总体高度
					navigationBarHeight: 0, // 导航栏高度(标题栏高度)
				},
				content:"",
			}
		},
		onLoad() {
			this.getNavbarHeight()
			this.getConfig()
		},
		methods:{
			
		async getConfig(){
				let res = await config()
				if(res.code == 1000){
					this.content = graceRichText.format(res.data[2].value)
				}
			},
			
			
			
			getNavbarHeight() {
				// 状态栏高度
				this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
			
				// #ifdef MP-WEIXIN
				// 获取微信胶囊的位置信息 width,height,top,right,left,bottom
				const custom = wx.getMenuButtonBoundingClientRect()
				// console.log(custom)
			
				// 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
				this.globalData.navigationBarHeight = custom.height + (custom.top - this.globalData.statusBarHeight) * 2
				// console.log("导航栏高度："+this.globalData.navigationBarHeight)
			
				// 总体高度 = 状态栏高度 + 导航栏高度
				this.globalData.navHeight = this.globalData.navigationBarHeight + this.globalData.statusBarHeight
			
				// #endif
			
				console.log("高度", this.globalData)
			
			},
		}
	}
</script>

<style scoped lang="scss">
	.contenBox{
		padding: 30rpx;
		box-sizing: border-box;
	}
</style>